package com.zrq.jwtdemo.core.exception;

import com.zrq.jwtdemo.core.constant.Constant;
import lombok.Getter;
import lombok.NonNull;

/**
 * @Author: zrq
 * @CreateDate: 2020/12/3
 * @Version: 类说明：自定义异常
 */
@Getter
public class AppException extends RuntimeException {

    private final Integer code;

    private final String messages;

    public AppException(@NonNull String messages) {
        this.code = Constant.ERROR_CODE;
        this.messages = messages;
    }

    public AppException(@NonNull Integer code, @NonNull String messages,Throwable cause) {
        super(String.format("[%s] %s",code,messages),cause);
        this.code = code;
        this.messages = messages;
    }

    public AppException(@NonNull Integer code, @NonNull String messages) {
        this.code = code;
        this.messages = messages;
    }
}
